package ch.janotta.slawo.da;

import java.util.HashMap;

public enum CharacterClass {
  MAGE, ROGUE, WARRIOR, ;

  private static final HashMap<Ability, CharacterClass[]> CHARACTER_CLASSES_LOOKUP_TABLE = new HashMap<>();
  static {
    CHARACTER_CLASSES_LOOKUP_TABLE.put(Ability.Communication, new CharacterClass[] { ROGUE });
    CHARACTER_CLASSES_LOOKUP_TABLE.put(Ability.Constitution,  new CharacterClass[] { WARRIOR });
    CHARACTER_CLASSES_LOOKUP_TABLE.put(Ability.Cunning,       new CharacterClass[] { MAGE });
    CHARACTER_CLASSES_LOOKUP_TABLE.put(Ability.Dexterity,     new CharacterClass[] { ROGUE, WARRIOR });
    CHARACTER_CLASSES_LOOKUP_TABLE.put(Ability.Magic,         new CharacterClass[] { MAGE });
    CHARACTER_CLASSES_LOOKUP_TABLE.put(Ability.Perception,    new CharacterClass[] { ROGUE });
    CHARACTER_CLASSES_LOOKUP_TABLE.put(Ability.Strength,      new CharacterClass[] { WARRIOR });
    CHARACTER_CLASSES_LOOKUP_TABLE.put(Ability.Willpower,     new CharacterClass[] { MAGE });
  }
  private static final HashMap<CharacterClass, Ability[]> PRIMARY_ABILITIES_LOOKUP_TABLE = new HashMap<>();
  static {
    PRIMARY_ABILITIES_LOOKUP_TABLE.put(MAGE,    new Ability[] { Ability.Cunning, Ability.Magic, Ability.Willpower });
    PRIMARY_ABILITIES_LOOKUP_TABLE.put(ROGUE,   new Ability[] { Ability.Communication, Ability.Dexterity, Ability.Perception });
    PRIMARY_ABILITIES_LOOKUP_TABLE.put(WARRIOR, new Ability[] { Ability.Constitution, Ability.Dexterity, Ability.Strength });
  }

  public static CharacterClass[] bestClassesForAbilities(Entity entity) {
    Ability maxAbility = entity.getMaximumStartingAbility();
    return CHARACTER_CLASSES_LOOKUP_TABLE.get(maxAbility);
  }

  public Ability[] getPrimaryAbilities() {
    return PRIMARY_ABILITIES_LOOKUP_TABLE.get(this);
  }
}
